diff --git a/Makefile b/Makefile index e476f4e..da593cf 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,11 @@ all: $(MAKE) -C src all + $(MAKE) -C bin all install: $(MAKE) -C src install + $(MAKE) -C bin install clean: $(MAKE) -C src clean + $(MAKE) -C bin clean diff --git a/bin/Makefile b/bin/Makefile new file mode 100644 index 0000000..4dd0324 --- /dev/null +++ b/bin/Makefile @@ -0,0 +1,30 @@ +include ../mk/build.mk + +CC = $(CROSS)cc + +INCLUDE_PATH = ../include + +CFLAGS += -I$(INCLUDE_PATH) +LDFLAGS = + +CAMMY = cammy +CAMMY_OBJS = pnglite.o main.o +CAMMY_HEADERS = pnglite.h +CAMMY_LDFLAGS = ../src/libcammy.a -lz + +PROGRAMS = cammy + +RM = /bin/rm +INSTALL = /usr/bin/install + +all: $(PROGRAMS) + +$(CAMMY): $(CAMMY_OBJS) $(CAMMY_HEADERS) + $(CC) $(CAMMY_OBJS) -o $@ $(CAMMY_LDFLAGS) + +install: $(PROGRAMS) + $(INSTALL) -d -m 0755 $(PREFIX)/bin + $(INSTALL) -c -m 0755 $(PROGRAMS) $(PREFIX)/bin + +clean: + $(RM) -f $(PROGRAMS) $(CAMMY_OBJS) diff --git a/src/test.c b/bin/main.c similarity index 100% rename from src/test.c rename to bin/main.c diff --git a/src/pnglite.c b/bin/pnglite.c similarity index 100% rename from src/pnglite.c rename to bin/pnglite.c diff --git a/src/pnglite.h b/bin/pnglite.h similarity index 100% rename from src/pnglite.h rename to bin/pnglite.h diff --git a/configure b/configure index e02382c..b3ad4a0 100755 --- a/configure +++ b/configure @@ -1,7 +1,6 @@ #! /bin/sh OS=`uname -s` -PREFIX=/usr/local DEBUG=0 create_linux_config_h() { @@ -9,7 +8,6 @@ create_linux_config_h() { #ifndef _CONFIG_H #define _CONFIG_H #include -#define CAMMY_INSTALL_PREFIX "$PREFIX" #endif /* _CONFIG_H */ EOF } @@ -23,25 +21,26 @@ create_darwin_config_h() { #ifdef __LITTLE_ENDIAN__ #define __DO_SWAP_BYTES #endif /* _DO_SWAP_BYTES */ -#define CAMMY_INSTALL_PREFIX "$PREFIX" #endif /* _CONFIG_H */ EOF } create_common_build_mk() { if [ "$DEBUG" = 1 ]; then - cat < mk/build.mk -PREFIX = $PREFIX - + cat <<'EOF' > mk/build.mk CGFLAGS = -g -fno-inline EOF else - cat < mk/build.mk -PREFIX = $PREFIX - + cat <<'EOF' > mk/build.mk CGFLAGS = EOF fi + + cat <<'EOF' >> mk/build.mk +CWFLAGS = -Wall +COFLAGS = -O2 +CFLAGS = $(CGFLAGS) $(CWFLAGS) $(COFLAGS) +EOF } create_linux_build_mk() { @@ -50,9 +49,13 @@ create_linux_build_mk() { cat <<'EOF' >> mk/build.mk LLFLAGS = -shared -Wl,-soname=$(SONAME) +STATIC = lib$(LIBNAME).a + SONAME_SHORT = lib$(LIBNAME).so SONAME = $(SONAME_SHORT).$(VERSION_MAJOR) SONAME_FULL = $(SONAME_SHORT).$(VERSION) + +PREFIX = /usr/local EOF } @@ -64,9 +67,11 @@ LLFLAGS = -dynamiclib -current_version $(VERSION) STATIC = lib$(LIBNAME).a -SONAME_SHORT = $(LIBNAME).dylib +SONAME_SHORT = lib$(LIBNAME).dylib SONAME = lib$(LIBNAME).$(VERSION_MAJOR).dylib SONAME_FULL = lib$(LIBNAME).$(VERSION).dylib + +PREFIX = /usr/local EOF } diff --git a/src/Makefile b/src/Makefile index bd7c991..16824b9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -7,14 +7,20 @@ CC = $(CROSS)cc CFLAGS = $(CGFLAGS) -fPIC -Wall -O2 -I$(INCLUDE_PATH) LDFLAGS = -lz -HEADERS_LOCAL = pnglite.h +HEADERS_LOCAL = HEADERS_BUILD = $(HEADERS_LOCAL) \ $(addprefix $(INCLUDE_PATH)/$(HEADER_SUBDIR)/,$(HEADERS)) HEADERS = sram.h photo.h -OBJS = sram.o photo.o pnglite.o test.o +OBJS = sram.o photo.o -PROGRAM = test +VERSION_MAJOR = 0 +VERSION_MINOR = 0.1 +VERSION = $(VERSION_MAJOR).$(VERSION_MINOR) + +LIBNAME = cammy + +STATIC = libcammy.a AR = $(CROSS)ar RANLIB = $(CROSS)ranlib @@ -24,13 +30,14 @@ LN = /bin/ln RMDIR = /bin/rmdir INSTALL = /usr/bin/install -all: $(PROGRAM) +all: $(STATIC) -$(PROGRAM): $(OBJS) - $(CC) $(OBJS) $(LDFLAGS) -o $(PROGRAM) +$(STATIC): $(OBJS) + $(AR) rc $(STATIC) $(OBJS) + $(RANLIB) $(STATIC) $(OBJS): %.o: %.c $(HEADERS_BUILD) $(CC) $(CFLAGS) -c $< clean: - $(RM) -f $(PROGRAM) $(OBJS) + $(RM) -f $(STATIC) $(OBJS)