123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- CC = $(CROSS_COMPILE)gcc
- AR = $(CROSS_COMPILE)ar
- LD = $(CROSS_COMPILE)ld
- LDCONF = /sbin/ldconfig
- CFLAGS_BASE=-O3 -Wall -g
- CFLAGS += $(CFLAGS_BASE) -fpic
- CROSS_FLAGS="-DBUILD_DLL -DDLL"
- PRJNAME = temelia
- LIBNAME = lib$(PRJNAME).so.1
- SVN_VER = $(shell svn info | cut -f2 -d" " | head -5 | tail -1)
- LIBREALNAME := $(LIBNAME).$(SVN_VER)
- LIBSYMNAME = lib$(PRJNAME).so
- SRCDIR = src
- HDRDIR = $(SRCDIR)/include
- DEBDIR = deb
- RPMDIR = rpm
- ARCH_32 = i386
- ARCH_64 = amd64
- LOCINCDIR = usr/include/$(PRJNAME)
- LOCLIBDIR = usr/lib
- PKGNAME_32 = $(PRJNAME)-1.0.$(SVN_VER)-1.$(ARCH_32)
- PKGNAME_64 = $(PRJNAME)-1.0.$(SVN_VER)-1.$(ARCH_64)
- DEBFS = filesystem
- CTRLBKP_FILE = control.sav
- DEBIAN_DIR = $(DEBFS)/DEBIAN
- CTRL_FILE = $(DEBIAN_DIR)/control
- POSTINST_FILE = $(DEBIAN_DIR)/postinst
- PRERM_FILE = $(DEBIAN_DIR)/prerm
- SIZE = `du $(DEBFS)/$(LOCINCDIR) | cut -f1`
- HDRS = $(HDRDIR)/*.h
- OBJS = $(shell ls $(SRCDIR)/*.c|tr '\n' ' '|sed -n -e s/\\.c/.o/gp)
- all: $(LIBREALNAME)
- $(LIBREALNAME): $(OBJS)
- $(CC) -shared -Wl,-soname,$(LIBNAME) -o $(LIBREALNAME) $(OBJS) -lc
- .c.o:
- ifeq ($(CC), gcc)
- $(CC) $(CFLAGS) -c "$<" -o "$@"
- else
- $(CC) $(CROSS_FLAGS) $(CFLAGS_BASE) -c "$<" -o "$@"
- endif
- install: $(LIBREALNAME)
- -mkdir -p /$(LOCINCDIR)
- cp $(HDRS) /$(LOCINCDIR)
- -mkdir -p /$(LOCLIBDIR)
- cp $(LIBREALNAME) $(DESTDIR)/$(LOCLIBDIR)
- ln -s /$(LOCLIBDIR)/$(LIBREALNAME) /$(LOCLIBDIR)/$(LIBNAME)
- ln -s /$(LOCLIBDIR)/$(LIBREALNAME) /$(LOCLIBDIR)/$(LIBSYMNAME)
- $(LDCONF)
- deb32: $(LIBREALNAME) $(DEBDIR)/$(ARCH_32)/$(PKGNAME_32).deb
- deb64: $(LIBREALNAME) $(DEBDIR)/$(ARCH_64)/$(PKGNAME_64).deb
- $(DEBDIR)/$(ARCH_32)/$(PKGNAME_32).deb: $(DEBDIR)/$(ARCH_32)
- -mkdir -p $</$(DEBFS)/$(LOCINCDIR)
- cp $(HDRS) $</$(DEBFS)/$(LOCINCDIR)
- -mkdir -p $</$(DEBFS)/$(LOCLIBDIR)
- cp $(LIBREALNAME) $</$(DEBFS)/$(LOCLIBDIR)
- -mkdir -p $</$(DEBIAN_DIR)
- echo "#!/bin/bash" >$</$(POSTINST_FILE)
- echo "ln -s /$(LOCLIBDIR)/$(LIBREALNAME) /$(LOCLIBDIR)/$(LIBNAME)" >>$</$(POSTINST_FILE)
- echo "ln -s /$(LOCLIBDIR)/$(LIBREALNAME) /$(LOCLIBDIR)/$(LIBSYMNAME)" >>$</$(POSTINST_FILE)
- echo "$(LDCONF)" >>$</$(POSTINST_FILE)
- echo "#!/bin/bash" >$</$(PRERM_FILE)
- echo "rm /$(LOCLIBDIR)/$(LIBSYMNAME)*" >>$</$(PRERM_FILE)
- echo "rm -r /$(LOCINCDIR)" >>$</$(PRERM_FILE)
- chmod +x $</$(POSTINST_FILE) $</$(PRERM_FILE)
- cp $</$(CTRLBKP_FILE) $</$(CTRL_FILE)
- echo "Installed-Size: $(SIZE)" >>$</$(CTRL_FILE)
- echo "Version: 1.0.$(SVN_VER)" >>$</$(CTRL_FILE)
- dpkg -b $</$(DEBFS) $</$(PKGNAME_32).deb
- $(DEBDIR)/$(ARCH_64)/$(PKGNAME_64).deb: $(DEBDIR)/$(ARCH_64)
- -mkdir -p $</$(DEBFS)/$(LOCINCDIR)
- cp $(HDRS) $</$(DEBFS)/$(LOCINCDIR)
- -mkdir -p $</$(DEBFS)/$(LOCLIBDIR)
- cp $(LIBREALNAME) $</$(DEBFS)/$(LOCLIBDIR)
- -mkdir -p $</$(DEBIAN_DIR)
- echo "#!/bin/bash" >$</$(POSTINST_FILE)
- echo "ln -s /$(LOCLIBDIR)/$(LIBREALNAME) /$(LOCLIBDIR)/$(LIBNAME)" >>$</$(POSTINST_FILE)
- echo "ln -s /$(LOCLIBDIR)/$(LIBREALNAME) /$(LOCLIBDIR)/$(LIBSYMNAME)" >>$</$(POSTINST_FILE)
- echo "$(LDCONF)" >>$</$(POSTINST_FILE)
- echo "#!/bin/bash" >$</$(PRERM_FILE)
- echo "rm /$(LOCLIBDIR)/$(LIBSYMNAME)*" >>$</$(PRERM_FILE)
- echo "rm -r /$(LOCINCDIR)" >>$</$(PRERM_FILE)
- chmod +x $</$(POSTINST_FILE) $</$(PRERM_FILE)
- cp $</$(CTRLBKP_FILE) $</$(CTRL_FILE)
- echo "Installed-Size: $(SIZE)" >>$</$(CTRL_FILE)
- echo "Version: 1.0.$(SVN_VER)" >>$</$(CTRL_FILE)
- dpkg -b $</$(DEBFS) $</$(PKGNAME_64).deb
- rpm32: deb32 $(RPMDIR)/$(ARCH_32)/$(PKGNAME_32).rpm
- rpm64: deb64 $(RPMDIR)/$(ARCH_64)/$(PKGNAME_64).rpm
- $(RPMDIR)/$(ARCH_32)/$(PKGNAME_32).rpm: $(RPMDIR)/$(ARCH_32)
- -mkdir -p $<
- cd $<; alien -rck ../../$(DEBDIR)/$(ARCH_32)/$(PKGNAME_32).deb
- $(RPMDIR)/$(ARCH_64)/$(PKGNAME_64).rpm: $(RPMDIR)/$(ARCH_64)
- dll: $(OBJS)
- $(CC) -shared -o $(PRJNAME).dll -Wl,--out-implib,lib$(PRJNAME)dll.a $(OBJS)
- dll_clean:
- -rm -rf $(PRJNAME).dll lib$(PRJNAME)dll.a
- -rm -f $(OBJS)
- debclean:
- rm -rf $(DEBDIR)/$(ARCH_32)/$(DEBFS) $(DEBDIR)/$(ARCH_64)/$(DEBFS)
- rm -f $(DEBDIR)/$(ARCH_32)/*.deb $(DEBDIR)/$(ARCH_64)/*.deb
- rpmclean:
- rm -rf $(RPMDIR)/$(ARCH_32)/*.rpm $(RPMDIR)/$(ARCH_64)/*.rpm
-
- clean: debclean rpmclean
- rm -f $(OBJS) $(LIBSYMNAME)*
- uninstall:
- -rm -r /$(LOCINCDIR)
- -rm /$(LOCLIBDIR)/$(LIBSYMNAME)*
- .PHONY: clean debclean uninstall
|