parlib: Expand our printf hacks
[akaros.git] / user / Makefrag-user-lib
index 8af4829..2e27ad9 100644 (file)
@@ -3,15 +3,14 @@
 # e.g.  LIBNAME = parlib
 
 ARCH ?= none   # catch bugs
+SRCDIR ?=
+INCDIR ?= $(SRCDIR)include
+OBJDIR ?= $(SRCDIR)obj
 CFLAGS_USER += $(CFLAGS_USER_LIBS)
 # DEPLIBS passed in from the top-level Makefile
 DEPLIBS := $(DEPLIBS)
 DEPLIBAS = $(patsubst %, $(XCC_TARGET_LIB)/lib%.a, $(DEPLIBS))
 
-SRCDIR :=
-OBJDIR := $(SRCDIR)obj
-INCDIR = $(SRCDIR)include
-
 INCS = -I$(INCDIR)
 FINALLIB = $(OBJDIR)/lib$(LIBNAME).a
 FINALLIB-INSTALL = $(XCC_TARGET_LIB)/lib$(LIBNAME).a
@@ -44,13 +43,15 @@ $(FINALLIB): $(OBJS)
        @mkdir -p $(@D)
        $(Q)$(AR) rc $@ $(OBJS)
 
-# The last rm is for the symlink
+# Allow two different patterns for installing include files
 $(FINALLIB-INSTALL): $(FINALLIB)
        @cp $(FINALLIB) $@
-       @rm -rf $(XCC_TARGET_INCLUDE)/$(LIBNAME)
-       @mkdir $(XCC_TARGET_INCLUDE)/$(LIBNAME)
-       @cp -r $(INCDIR)/* $(XCC_TARGET_INCLUDE)/$(LIBNAME)/
-       @rm $(XCC_TARGET_INCLUDE)/$(LIBNAME)/$(LIBNAME)
+       @if [ -d "$(INCDIR)/$(LIBNAME)" ]; then \
+               rm -rf $(XCC_TARGET_INCLUDE)/$(LIBNAME) ; \
+               cp -r $(INCDIR)/$(LIBNAME) $(XCC_TARGET_INCLUDE)/ ; \
+       else \
+               cp -r $(INCDIR)/*.h $(XCC_TARGET_INCLUDE)/ ; \
+       fi;
 
 install: $(FINALLIB-INSTALL)
        @echo > /dev/null