Skip to content

Commit

Permalink
quote rethinking in mk (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
babongo committed Jun 22, 2010
1 parent 5a69cd8 commit d22c64b
Show file tree
Hide file tree
Showing 48 changed files with 248 additions and 230 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -4,6 +4,7 @@ ChangeLog file of MaKL - http://www.koanlogic.com/makl/changelog.html

MaKL X.Y.Z
- pkgs: rel-git.sh removed makl dependency for dist
- mk: global rethink of quote handling

MaKL 1.8.2
- cf: fixed broken disabling of features ; safer tmp dir and better error ;
Expand Down
27 changes: 1 addition & 26 deletions TODO
@@ -1,30 +1,5 @@
* avoid multiple inclusion of .mk files (i.e. ifndef __prog_mk__ ... endif)
* check preconditions for all the user supplied variables needed by .mk files
(i.e. mk_precond function needed)
* more testing needed for shared libraries on BSD platforms
* cf/makl_{answer,question} for interactive settings
* a better integration with GNU make internal variables' data base ?

* it would be nice to have "makl-nutshells", i.e. private and self-contained
makl environments: they'd be created and accessed easily (with minimal
user intervention) and would be "local" to a given user or build context.

makl nutshell MAKL_NUTSHELL=/makl/nutshell/dir \
MAKL_PLATFORM=/my/makl/toolchain_and_sharedlib_basename

or:

makl nutshell MAKL_NUTSHELL=/makl/nutshell/dir \
MAKL_TC=/my/makl/toolchain_file \
MAKL_SHLIB=/my/makl/shlib_file

if MAKL_SHLIB is not set null.shlib will be used

* set of bourne shell helper functions for common tasks that can be invoked
via 'call'

* makl-new <lib|prog|subdir|xeno|include|script|file|man|dist>
takes a template file and writes it to the current working dir

* add 'help' target to each .mk template that shows available variables
and target it exports
* add un-quote and escape function to handle quoted paths and paths with holes
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
1.8.2
1.8.3rc0
2 changes: 1 addition & 1 deletion bin/lib/Makefile
Expand Up @@ -10,7 +10,7 @@ FILES += maklsh_help
FILES += maklsh_new
FILES += maklsh_run
FILES += maklsh_tc
FILES_DIR = "$(MAKL_ROOT)/maklsh"
FILES_DIR = $(MAKL_ROOT)/maklsh
FILES_MODE = 0644

include files.mk
2 changes: 1 addition & 1 deletion cf/Makefile
Expand Up @@ -4,7 +4,7 @@ include common.mk
include ../Makefile.conf

FILES = $(shell echo makl*)
FILES_DIR = "$(MAKL_ROOT)/cf"
FILES_DIR = $(MAKL_ROOT)/cf
FILES_MODE = 0444

SUBDIR = helpers
Expand Down
2 changes: 1 addition & 1 deletion cf/helpers/Makefile
Expand Up @@ -4,7 +4,7 @@ include common.mk
include ../../Makefile.conf

FILES = $(shell echo makl_*)
FILES_DIR = "$(MAKL_ROOT)/cf/helpers"
FILES_DIR = $(MAKL_ROOT)/cf/helpers
FILES_MODE = 0444

include files.mk
2 changes: 1 addition & 1 deletion etc/Makefile
Expand Up @@ -4,7 +4,7 @@ include common.mk
include ../Makefile.conf

FILES = $(shell echo *.cf *.mk)
FILES_DIR = "$(MAKL_ROOT)/etc"
FILES_DIR = $(MAKL_ROOT)/etc
FILES_MODE = 0444

include files.mk
2 changes: 1 addition & 1 deletion helpers/Makefile
Expand Up @@ -4,7 +4,7 @@ include common.mk
include ../Makefile.conf

FILES = lorder mkdep.gcc.sh mkinstalldirs
FILES_DIR = "$(MAKL_ROOT)/helpers"
FILES_DIR = $(MAKL_ROOT)/helpers
FILES_MODE = 0555

include files.mk
2 changes: 1 addition & 1 deletion misc/Makefile
Expand Up @@ -4,7 +4,7 @@ include common.mk
include ../Makefile.conf

FILES = ../VERSION ../LICENSE ../Makefile
FILES_DIR = "$(MAKL_ROOT)"
FILES_DIR = $(MAKL_ROOT)
FILES_MODE = 0444

include files.mk
2 changes: 1 addition & 1 deletion mk/Makefile
Expand Up @@ -4,7 +4,7 @@ include common.mk
include ../Makefile.conf

FILES = $(shell echo *.mk)
FILES_DIR = "$(MAKL_ROOT)/mk"
FILES_DIR = $(MAKL_ROOT)/mk
FILES_MODE = 0444

SUBDIR = priv
Expand Down
46 changes: 23 additions & 23 deletions mk/dist.mk
Expand Up @@ -58,10 +58,10 @@ realdist: normaldist distrecipe remapdist
ifdef DISTFILES
normaldist:
@for f in $(DISTFILES); do \
dir=`dirname $$f` && \
file=`basename $$f` && \
$(MKINSTALLDIRS) $(DISTDIR)/$$dir && \
cp -fpR $$dir/$$file $(DISTDIR)/$$dir/$$file ; \
dir="`dirname "$$f"`" && \
file="`basename "$$f"`" && \
$(MKINSTALLDIRS) "$(DISTDIR)/$$dir" && \
$(CP) -fpR "$$dir/$$file" "$(DISTDIR)/$$dir/$$file" ; \
done
else # !DISTFILES
normaldist:
Expand All @@ -70,10 +70,10 @@ endif # DISTFILES
ifdef DISTRECIPE
distrecipe:
@cat $(DISTRECIPE) | while read f; do \
dir=`dirname "$$f"` && \
file=`basename "$$f"` && \
dir="`dirname "$$f"`" && \
file="`basename "$$f"`" && \
$(MKINSTALLDIRS) "$(DISTDIR)/$$dir" && \
cp -fpR "$$dir/$$file" "$(DISTDIR)/$$dir/$$file" ; \
$(CP) -fpR "$$dir/$$file" "$(DISTDIR)/$$dir/$$file" ; \
done
else # !DISTFILES
distrecipe:
Expand All @@ -83,11 +83,11 @@ endif # DISTFILES
ifdef DISTREMAP
remapdist:
@set $(DISTREMAP); \
while test $$# -ge 2 ; do \
in=$$1 ; shift ; \
out=$$1 ; shift ; \
$(MKINSTALLDIRS) $(DISTDIR)/`dirname $$out` && \
cp -fPR $$in $(DISTDIR)/$$out ; \
while test "$$#" -ge 2 ; do \
in="$$1" ; shift ; \
out="$$1" ; shift ; \
$(MKINSTALLDIRS) "$(DISTDIR)/`dirname $$out`" && \
$(CP) -fPR "$$in" "$(DISTDIR)/$$out" ; \
done
else # !DISTREMAP
remapdist:
Expand All @@ -97,19 +97,19 @@ olddir=$(shell pwd)
ifdef PKG_NODIR
tarball:
@cd $(DISTDIR) && \
$(TAR) $(TAR_ARGS) $(olddir)/$(DISTNAME).tar . && \
rm -f $(olddir)/$(DISTNAME).tar.$(ZIPEXT) && \
$(ZIP) $(olddir)/$(DISTNAME).tar && \
$(TAR) $(TAR_ARGS) "$(olddir)/$(DISTNAME).tar" . && \
$(RM) "$(olddir)/$(DISTNAME).tar.$(ZIPEXT)" && \
$(ZIP) "$(olddir)/$(DISTNAME).tar" && \
cd - && \
$(MD5SUM) $(DISTNAME).tar.$(ZIPEXT) > $(DISTNAME).tar.$(ZIPEXT).md5 && \
rm -rf $(DISTNAME).tar $(DISTDIR)
$(MD5SUM) "$(DISTNAME).tar.$(ZIPEXT)" > "$(DISTNAME).tar.$(ZIPEXT).md5" && \
$(RM) -r "$(DISTNAME).tar" "$(DISTDIR)"
else
tarball:
@$(TAR) $(TAR_ARGS) $(DISTNAME).tar $(DISTDIR) && \
rm -f $(DISTNAME).tar.$(ZIPEXT) && \
$(ZIP) $(DISTNAME).tar && \
$(MD5SUM) $(DISTNAME).tar.$(ZIPEXT) > $(DISTNAME).tar.$(ZIPEXT).md5 && \
rm -rf $(DISTNAME).tar $(DISTDIR)
@$(TAR) $(TAR_ARGS) "$(DISTNAME).tar" "$(DISTDIR)" && \
$(RM) "$(DISTNAME).tar.$(ZIPEXT)" && \
$(ZIP) "$(DISTNAME).tar" && \
$(MD5SUM) "$(DISTNAME).tar.$(ZIPEXT)" > "$(DISTNAME).tar.$(ZIPEXT).md5" && \
$(RM) -r "$(DISTNAME).tar" "$(DISTDIR)"
endif

##
Expand All @@ -120,7 +120,7 @@ distclean: distclean-hook-pre realdistclean distclean-hook-post
distclean-hook-pre distclean-hook-post:

realdistclean:
rm -rf $(DISTNAME)*
$(RM) -r $(DISTNAME)*

# Make sure all of the standard targets are defined, even if they do nothing.
all install uninstall clean depend cleandepend:
Expand Down
2 changes: 1 addition & 1 deletion mk/distclean.mk
Expand Up @@ -2,7 +2,7 @@

ifdef DISTCLEANFILES
distclean: clean
rm -f $(DISTCLEANFILES)
$(RM) $(DISTCLEANFILES)
else
distclean: clean
endif
10 changes: 5 additions & 5 deletions mk/files.mk
Expand Up @@ -60,14 +60,14 @@ __CHOWN_ARGS = $(call calc-chown-args, $(FILES_OWN), $(FILES_GRP))
__INSTALL_ARGS = $(call calc-install-args, $(FILES_OWN), $(FILES_GRP))

$(FILES_DIR):
$(MKINSTALLDIRS) $(FILES_DIR)
$(MKINSTALLDIRS) "$(FILES_DIR)"
ifneq ($(strip $(__CHOWN_ARGS)),)
chown $(__CHOWN_ARGS) $(FILES_DIR)
chown $(__CHOWN_ARGS) "$(FILES_DIR)"
endif

realinstall: $(FILES_DIR)
$(INSTALL) $(INSTALL_COPY) $(__INSTALL_ARGS) -m $(FILES_MODE) $(FILES) \
$(FILES_DIR)
"$(FILES_DIR)"

install-hook-pre install-hook-post:

Expand All @@ -83,9 +83,9 @@ uninstall: uninstall-hook-pre realuninstall uninstall-hook-post

realuninstall:
for f in $(FILES); do \
rm -f $(FILES_DIR)/`basename $$f` ; \
$(RM) "$(FILES_DIR)/`basename "$$f"`" ; \
done
-rmdir $(FILES_DIR) 2>/dev/null
-rmdir "$(FILES_DIR)" 2>/dev/null

uninstall-hook-pre uninstall-hook-post:

Expand Down
12 changes: 6 additions & 6 deletions mk/incs.mk
@@ -1,4 +1,4 @@
#

# $Id: incs.mk,v 1.29 2008/06/13 21:09:31 tho Exp $
#
# Only define the install and uninstall targets.
Expand Down Expand Up @@ -73,13 +73,13 @@ __CHOWN_ARGS = $(call calc-chown-args, $(INCOWN), $(INCGRP))
__INSTALL_ARGS = $(call calc-install-args, $(INCOWN), $(INCGRP))

$(INCDIR):
$(MKINSTALLDIRS) $(INCDIR)
$(MKINSTALLDIRS) "$(INCDIR)"
ifneq ($(strip $(__CHOWN_ARGS)),)
chown $(__CHOWN_ARGS) $(INCDIR)
chown $(__CHOWN_ARGS) "$(INCDIR)"
endif

realinstall: $(INCDIR)
$(INSTALL) $(__INSTALL_ARGS) -m $(INCMODE) $(INCS) $(INCDIR)
$(INSTALL) $(__INSTALL_ARGS) -m $(INCMODE) $(INCS) "$(INCDIR)"

else
install:
Expand All @@ -95,9 +95,9 @@ uninstall-hook-pre uninstall-hook-post:

realuninstall:
for f in $(INCS); do \
rm -f $(INCDIR)/`basename $$f`; \
$(RM) "$(INCDIR)/`basename "$$f"`"; \
done
-rmdir $(INCDIR) 2>/dev/null
-rmdir "$(INCDIR)" 2>/dev/null

else
uninstall:
Expand Down
14 changes: 7 additions & 7 deletions mk/lib.mk
Expand Up @@ -70,7 +70,7 @@ all-static: $(LIB_NAME)
# always create archive ex-nihil
$(LIB_NAME): $(OBJS)
@echo "===> building standard $(__LIB) library"
rm -f $@
$(RM) $@
$(AR) $(ARFLAGS) $@ `$(LORDER) $^ | $(TSORT)`
$(RANLIB) $@

Expand All @@ -88,7 +88,7 @@ clean: clean-hook-pre clean-static clean-shared clean-hook-post
CLEANFILES += $(OBJS) $(LIB_NAME)

clean-static:
rm -f $(CLEANFILES)
$(RM) $(CLEANFILES)

clean-hook-pre clean-hook-post:
else
Expand All @@ -111,15 +111,15 @@ __CHOWN_ARGS = $(call calc-chown-args, $(LIBOWN), $(LIBGRP))
__INSTALL_ARGS = $(call calc-install-args, $(LIBOWN), $(LIBGRP))

$(LIBDIR):
$(MKINSTALLDIRS) $(LIBDIR)
$(MKINSTALLDIRS) "$(LIBDIR)"
ifneq ($(strip $(__CHOWN_ARGS)),)
chown $(__CHOWN_ARGS) $(LIBDIR)
chown $(__CHOWN_ARGS) "$(LIBDIR)"
endif

realinstall: $(LIBDIR) install-static install-shared

install-static:
$(INSTALL) $(__INSTALL_ARGS) -m $(LIBMODE) $(LIB_NAME) $(LIBDIR)
$(INSTALL) $(__INSTALL_ARGS) -m $(LIBMODE) $(LIB_NAME) "$(LIBDIR)"

install-hook-pre install-hook-post:

Expand All @@ -136,8 +136,8 @@ uninstall: uninstall-hook-pre realuninstall uninstall-hook-post
realuninstall: uninstall-static uninstall-shared

uninstall-static:
rm -f $(LIBDIR)/$(LIB_NAME)
-rmdir $(LIBDIR) 2>/dev/null
$(RM) "$(LIBDIR)/$(LIB_NAME)"
-rmdir "$(LIBDIR)" 2>/dev/null

uninstall-hook-pre uninstall-hook-post:

Expand Down
32 changes: 16 additions & 16 deletions mk/man.mk
Expand Up @@ -84,37 +84,37 @@ install-hook-pre install-hook-post:

dirs:
@for d in $(__SUBDIRS); do \
$(MKINSTALLDIRS) $(MANDIR)/man$$d ; \
$(MKINSTALLDIRS) "$(MANDIR)/man$$d" ; \
done

dirperms:
ifneq ($(strip $(__CHOWN_ARGS)),)
@for d in $(__SUBDIRS); do \
chown $(__CHOWN_ARGS) $(MANDIR)/man$$d ; \
chown $(__CHOWN_ARGS) "$(MANDIR)/man$$d" ; \
done
endif

realinstall:
@for f in $(MANFILES); do \
$(INSTALL) $(INSTALL_COPY) $(__INSTALL_ARGS) -m $(MANMODE) \
$$f $(MANDIR)/man$${f##*.} ; \
"$$f" "$(MANDIR)/man$${f##*.}" ; \
done

ifneq ($(MLINKS),)
manlinks:
@set $(MLINKS); \
while test $$# -ge 2 ; do \
name=$$1 ; \
while test "$$#" -ge 2 ; do \
name="$$1" ; \
shift ; \
dir=$(MANDIR)/man$${name##*.} ; \
l=$$dir/$$name ; \
name=$$1 ; \
dir="$(MANDIR)/man$${name##*.}" ; \
l="$$dir/$$name" ; \
name="$$1" ; \
shift ; \
dir=$(MANDIR)/man$${name##*.} ; \
t=$$dir/$$name ; \
if test $$l -nt $$t -o ! -f $$t ; then \
echo $$t -\> $$l ; \
ln -f $$l $$t ; \
dir="$(MANDIR)/man$${name##*.}" ; \
t="$$dir/$$name" ; \
if test "$$l" -nt "$$t" -o ! -f "$$t" ; then \
$(ECHO) "$$t" -\> "$$l" ; \
ln -f "$$l" "$$t" ; \
fi ; \
done
else
Expand All @@ -131,10 +131,10 @@ endif
ifndef NO_UNINSTALL
uninstall:
-for f in $(MLINKS) $(MANFILES) ; do \
rm -f $(MANDIR)/man$${f##*.}/$$f ; \
rmdir $(MANDIR)/man$${f##*.} 2>/dev/null; \
$(RM) "$(MANDIR)/man$${f##*.}/$$f" ; \
-rmdir "$(MANDIR)/man$${f##*.}" 2>/dev/null; \
done
-rmdir $(MANDIR) 2>/dev/null
-rmdir "$(MANDIR)" 2>/dev/null

else
uninstall:
Expand Down
2 changes: 1 addition & 1 deletion mk/priv/Makefile
Expand Up @@ -4,7 +4,7 @@ include common.mk
include ../../Makefile.conf

FILES = deps.mk funcs.mk obj.mk
FILES_DIR = "$(MAKL_ROOT)/mk/priv"
FILES_DIR = $(MAKL_ROOT)/mk/priv
FILES_MODE = 0444

include files.mk

0 comments on commit d22c64b

Please sign in to comment.