229
Makefile
Normal file
229
Makefile
Normal file
@ -0,0 +1,229 @@
|
||||
# This Makefile is created by AGentooCat
|
||||
# Cat'sMake v0.7.3 - under BSD-0-Clause.
|
||||
|
||||
# the settings for the to-be-built stuff is here
|
||||
include config.mk
|
||||
CATSVERSION=v0.7.3
|
||||
|
||||
.PHONY: all install install-bin install-lib clean
|
||||
|
||||
# set buildtype to debug if nothing is selected yet
|
||||
BUILDTYPE ?= Debug
|
||||
# and lowercase whatever is in there
|
||||
# (everybody has an implementation of tr, right?)
|
||||
buildtype = $(shell echo $(BUILDTYPE) | tr A-Z a-z)
|
||||
# the installer will consult these two
|
||||
# it will do "//usr/local" in this case.
|
||||
# ${DESTDIR}/${PREFIX} basically
|
||||
DESTDIR := /
|
||||
PREFIX := usr/local
|
||||
|
||||
# set typeflags for buildtype
|
||||
ifeq ("$(buildtype)", "debug")
|
||||
TYPEFLAGS = -O0 -g
|
||||
else ifeq ("$(buildtype)", "release")
|
||||
TYPEFLAGS = -O2 -g0
|
||||
else ifeq ("$(buildtype)", "relwithdebinfo")
|
||||
TYPEFLAGS = -O2 -g
|
||||
else ifeq ("$(buildtype)", "minsizerel")
|
||||
TYPEFLAGS = -Os -g0
|
||||
else
|
||||
TYPEFLAGS =
|
||||
endif
|
||||
|
||||
# set the defines for, well, #define's.
|
||||
_DEFINES=
|
||||
ifeq ($(NO_V_MACROS),)
|
||||
_DEFINES += -DVERSION='"$(VERSION)"'
|
||||
endif
|
||||
ifeq ($(NO_LV_MACROS),)
|
||||
_DEFINES += -DLIBVERSION='"$(LIBVERSION)"'
|
||||
endif
|
||||
_DEFINES += $(DEFINES)
|
||||
# the user can change C/ASM/LDFLAGS
|
||||
# (we're adding to FLAGS here by TYPEFLAGS btw)
|
||||
FLAGS += -Iinclude/ $(TYPEFLAGS)
|
||||
C_FLAGS = $(FLAGS) $(PROJ_C) $(_DEFINES) $(CFLAGS)
|
||||
ASM_FLAGS = $(FLAGS) $(PROJ_ASM) $(ASMFLAGS)
|
||||
LD_FLAGS = $(FLAGS) $(PROJ_LD) $(LDFLAGS)
|
||||
|
||||
_PROG_OBJS = $(foreach i, $(PROG_SRCS), obj/$(i).o)
|
||||
_LIB_OBJS = $(foreach i, $(LIB_SRCS), obj/lib/$(i).o)
|
||||
_LIB_HEADS = $(foreach i, $(LIB_HEADS), include/$(i))
|
||||
|
||||
ifeq ($(PROGNAME),)
|
||||
ifeq ($(LIBNAME),)
|
||||
all:
|
||||
@echo "--> No program or library specified to build!"
|
||||
@echo "--> This is a project error, contact the project maintainer for a fix."
|
||||
@exit 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# set LIBNAME in config.mk as empty to disable library
|
||||
# set PROGNAME in config.mk as empty to disable program
|
||||
ifdef LIBNAME
|
||||
_lib=lib
|
||||
else
|
||||
_lib=
|
||||
endif
|
||||
all: $(_lib) $(PROGNAME)
|
||||
|
||||
# (just a quick dir-create patch - nothing bad here)
|
||||
%/:
|
||||
@mkdir -pv $@
|
||||
# hopefully
|
||||
|
||||
ifdef PROGNAME
|
||||
ifdef LIBNAME
|
||||
_lib=lib$(LIBNAME).a
|
||||
else
|
||||
_lib=
|
||||
endif
|
||||
|
||||
ifeq ("$(shell test -r build_bin.c && echo yes)", "yes")
|
||||
_build_bin=build-bin
|
||||
build-bin: build_bin.c
|
||||
$(info $(PROGNAME): Building/running build script...)
|
||||
ifeq ($V,1)
|
||||
$(CC) -O2 -pipe -o build-bin build_bin.c $(BUILD_BIN)
|
||||
./build-bin
|
||||
else
|
||||
@$(CC) -O2 -pipe -o build-bin build_bin.c $(BUILD_BIN)
|
||||
@./build-bin
|
||||
endif
|
||||
endif
|
||||
|
||||
# in case the program is enabled, config.mk:PROG_OBJS MUST set objects to build
|
||||
ifeq ($(PROG_SRCS),)
|
||||
.PHONY: $(PROGNAME)
|
||||
$(PROGNAME):
|
||||
$(error $(PROGNAME): No source files specified to build for program!)
|
||||
|
||||
else
|
||||
$(PROGNAME): obj/ $(_lib) $(_PROG_OBJS) $(_build_bin)
|
||||
$(info $(PROGNAME): Now linking program $(PROGNAME)...)
|
||||
ifeq ($V,1)
|
||||
$(CC) $(LD_FLAGS) -o $(PROGNAME) $(_PROG_OBJS) $(_lib) $(PROG_LIBS)
|
||||
else
|
||||
@$(CC) $(LD_FLAGS) -o $(PROGNAME) $(_PROG_OBJS) $(_lib) $(PROG_LIBS)
|
||||
endif
|
||||
endif
|
||||
|
||||
obj/%.c.o: src/%.c $(_build_bin)
|
||||
$(info $(PROGNAME): Now building $@...)
|
||||
ifeq ($V,1)
|
||||
$(CC) $(C_FLAGS) -c -o $@ $<
|
||||
else
|
||||
@$(CC) $(C_FLAGS) -c -o $@ $<
|
||||
endif
|
||||
|
||||
obj/%.s.o: src/%.s $(_build_bin)
|
||||
$(info $(PROGNAME): Now building $@...)
|
||||
ifeq ($V,1)
|
||||
$(AS) $(ASM_FLAGS) -o $@ $<
|
||||
else
|
||||
@$(AS) $(ASM_FLAGS) -o $@ $<
|
||||
endif
|
||||
|
||||
install-bin: $(PROGNAME)
|
||||
@mkdir -pv $(DESTDIR)/$(PREFIX)/bin/
|
||||
@install -Dvm755 $(PROGNAME) $(DESTDIR)/$(PREFIX)/bin/
|
||||
else
|
||||
install-bin:
|
||||
@echo > /dev/null
|
||||
endif
|
||||
|
||||
ifdef LIBNAME
|
||||
|
||||
ifeq ("$(shell test -r build_lib.c && echo yes)", "yes")
|
||||
_build_lib=build-lib
|
||||
build-lib: build_lib.c
|
||||
$(info $(LIBNAME): Building/running build script...)
|
||||
ifeq ($V,1)
|
||||
$(CC) -O2 -pipe -o build-lib build_lib.c $(BUILD_LIB)
|
||||
./build-lib
|
||||
else
|
||||
@$(CC) -O2 -pipe -o build-lib build_lib.c $(BUILD_LIB)
|
||||
@./build-lib
|
||||
endif
|
||||
endif
|
||||
|
||||
# same logic as PROG_SRCS
|
||||
ifeq ($(LIB_SRCS),)
|
||||
.PHONY: lib$(LIBNAME).a lib$(LIBNAME).so
|
||||
lib$(LIBNAME).a: lib$(LIBNAME).so
|
||||
lib$(LIBNAME).so:
|
||||
$(error $(LIBNAME): No source files specified to build for library!)
|
||||
|
||||
else
|
||||
lib$(LIBNAME).a: obj/lib/ $(_LIB_OBJS) $(_build_lib)
|
||||
$(info $(LIBNAME): Now packing up static library lib$(LIBNAME).a...)
|
||||
ifeq ($V,1)
|
||||
$(AR) qvs lib$(LIBNAME).a $(_LIB_OBJS)
|
||||
else
|
||||
@$(AR) qs lib$(LIBNAME).a $(_LIB_OBJS)
|
||||
endif
|
||||
lib$(LIBNAME).so: obj/lib/ $(_LIB_OBJS) $(_build_lib)
|
||||
$(info $(LIBNAME): Now packing up shared library lib$(LIBNAME).so...)
|
||||
ifeq ($V,1)
|
||||
$(CC) $(LD_FLAGS) -o lib$(LIBNAME).so $(_LIB_OBJS) -shared
|
||||
else
|
||||
@$(CC) $(LD_FLAGS) -o lib$(LIBNAME).so $(_LIB_OBJS) -shared
|
||||
endif
|
||||
endif
|
||||
|
||||
obj/lib/%.c.o: src/lib/%.c $(_build_lib)
|
||||
$(info $(LIBNAME): Now building $@...)
|
||||
ifeq ($V,1)
|
||||
$(CC) $(C_FLAGS) -c -o $@ $<
|
||||
else
|
||||
@$(CC) $(C_FLAGS) -c -o $@ $<
|
||||
endif
|
||||
|
||||
obj/lib/%.c.o: src/lib/%.s $(_build_lib)
|
||||
$(info $(LIBNAME): Now building $@...)
|
||||
ifeq ($V,1)
|
||||
$(AS) $(ASM_FLAGS) -o $@ $<
|
||||
else
|
||||
@$(AS) $(ASM_FLAGS) -o $@ $<
|
||||
endif
|
||||
|
||||
install-lib: lib$(LIBNAME).a lib$(LIBNAME).so
|
||||
@mkdir -pv $(DESTDIR)/$(PREFIX)/lib/
|
||||
@mkdir -pv $(DESTDIR)/$(PREFIX)/include/
|
||||
@install -Dvm644 lib$(LIBNAME).a lib$(LIBNAME).so $(DESTDIR)/$(PREFIX)/lib/
|
||||
@install -Dvm644 $(_LIB_HEADS) $(DESTDIR)/$(PREFIX)/include/
|
||||
lib: lib$(LIBNAME).a lib$(LIBNAME).so
|
||||
else
|
||||
install-lib:
|
||||
@echo > /dev/null
|
||||
lib: install-lib
|
||||
endif
|
||||
|
||||
ifdef ETC_DATA
|
||||
_ETC_SRC = $(foreach i, $(ETC_DATA), contrib/$(i))
|
||||
_ETC_DST = $(foreach i, $(ETC_DATA), $(DESTDIR)/etc/$(i))
|
||||
install-etc: $(_ETC_DST)
|
||||
$(DESTDIR)/etc/%: contrib/%
|
||||
@install -Dvm644 $< $@
|
||||
else
|
||||
install-etc:
|
||||
@echo > /dev/null
|
||||
endif
|
||||
|
||||
ifdef SHR_DATA
|
||||
_SHR_SRC = $(foreach i, $(SHR_DATA), contrib/$(i))
|
||||
_SHR_DST = $(foreach i, $(SHR_DATA), $(DESTDIR)/$(PREFIX)/share/$(i))
|
||||
install-shr: $(_SHR_DST)
|
||||
$(DESTDIR)/$(PREFIX)/share/%: contrib/%
|
||||
@install -Dvm644 $< $@
|
||||
else
|
||||
install-shr:
|
||||
@echo > /dev/null
|
||||
endif
|
||||
|
||||
clean:
|
||||
@rm -rfv obj/ lib$(LIBNAME).a lib$(LIBNAME).so $(PROGNAME) build-lib build-bin
|
||||
|
||||
install: install-bin install-lib install-etc install-shr
|
1
README.md
Normal file
1
README.md
Normal file
@ -0,0 +1 @@
|
||||
`itoomail` is an implementation of Eep2Eep mail server idea (of mine) at [here](http://i2pforum.i2p/viewtopic.php?t=1268).
|
50
config.mk
Normal file
50
config.mk
Normal file
@ -0,0 +1,50 @@
|
||||
# This config.mk is created by AGentooCat
|
||||
# Cat'sMake v0.7.3 - under BSD-0-Clause
|
||||
|
||||
# set to the program's name to enable program building
|
||||
PROGNAME=itoomail
|
||||
VERSION=v0.0.0
|
||||
# same as PROGNAME (will be as lib(LIBNAME).(a|so))
|
||||
LIBNAME=
|
||||
LIBVERSION=v0.0.0
|
||||
|
||||
# FLAGS is C-and-LD stuff
|
||||
# PROJ_C is project's C flags.
|
||||
# PROJ_ASM is ASseMbly,
|
||||
# PROJ_LD is linker.
|
||||
# the user can change CFLAGS/ASMFLAGS/LDFLAGS which will override these flags
|
||||
# (if the compiler favors the last arguments over the first ones)
|
||||
FLAGS = -Wall -Wextra -pipe
|
||||
PROJ_C =
|
||||
PROJ_ASM=
|
||||
PROJ_LD =
|
||||
|
||||
# set the source files to be built for the program/library
|
||||
# dont prefix src/ or src/lib/
|
||||
PROG_SRCS=main.c
|
||||
LIB_SRCS=
|
||||
|
||||
# what the program depends on (-l<ib>)
|
||||
PROG_LIBS=
|
||||
|
||||
# if the library installs headers, place them under (root)/include
|
||||
# and add them here to be installed under (DESTDIR)/(PREFIX)/include
|
||||
# (omit "include/" part here)
|
||||
LIB_HEADS=
|
||||
|
||||
# you can specify misc files (placed under contrib/) to be installed
|
||||
# ETC: /etc/ files
|
||||
# SHR: /usr/share/ files
|
||||
ETC_DATA=
|
||||
SHR_DATA=
|
||||
|
||||
# starting with 0.7, CatsMake will look for "build_bin.c" or "build_lib.c"
|
||||
# to compile and run before the actual compilation (similar to Rust/Cargo's
|
||||
# "build.rs" feature). these will be compiled with "-O2 -pipe".
|
||||
# you can specify extra compilation flags here
|
||||
BUILD_BIN=-O2 -pipe
|
||||
BUILD_LIB=-O2 -pipe
|
||||
|
||||
# if you don't want to auto-add (LIB)VERSION macros, set these variables
|
||||
NO_V_MACROS=
|
||||
NO_LV_MACROS=
|
5
src/main.c
Normal file
5
src/main.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
fprintf(stderr, "Hello world! argc=%d argv=%p\n", argc, argv);
|
||||
}
|
Reference in New Issue
Block a user