trunk: changeset 55

Sat, 05 Apr 2003 22:32:55 +0200

author
tuomov
date
Sat, 05 Apr 2003 22:32:55 +0200
changeset 51
2d95d77aa954
parent 50
855953c2f413
child 52
0228b3741a42

trunk: changeset 55
stringintmap_value added

include/libtu/map.h file | annotate | diff | comparison | revisions
map.c file | annotate | diff | comparison | revisions
rules.mk file | annotate | diff | comparison | revisions
system.mk file | annotate | diff | comparison | revisions
--- a/include/libtu/map.h	Sat Apr 05 22:24:03 2003 +0200
+++ b/include/libtu/map.h	Sat Apr 05 22:32:55 2003 +0200
@@ -17,5 +17,7 @@
 
 /* Return the index of str in map or -1 if not found. */
 extern int stringintmap_ndx(const StringIntMap *map, const char *str);
-					 
+extern int stringintmap_value(const StringIntMap *map, const char *str,
+							  int dflt);
+
 #endif /* LIBTU_MAP_H */
--- a/map.c	Sat Apr 05 22:24:03 2003 +0200
+++ b/map.c	Sat Apr 05 22:32:55 2003 +0200
@@ -15,9 +15,16 @@
 	
 	for(i=0; map[i].string!=NULL; i++){
 		if(strcmp(str, map[i].string)==0)
-			return map[i].value;
+			return i;
 	}
 	
 	return -1;
 }
 
+
+int stringintmap_value(const StringIntMap *map, const char *str, int dflt)
+{
+    int i=stringintmap_ndx(map, str);
+	return (i==-1 ? dflt : map[i].value); 
+}
+
--- a/rules.mk	Sat Apr 05 22:24:03 2003 +0200
+++ b/rules.mk	Sat Apr 05 22:32:55 2003 +0200
@@ -4,13 +4,22 @@
 
 ######################################
 
+ifdef MODULE
+ifneq ($(STATIC_MODULES),1)
+TARGETS := $(TARGETS) $(MODULE).so
+else
+TARGETS := $(TARGETS) $(MODULE).a
+endif
+endif
+
+
 ifdef SUBDIRS
 
 all: subdirs $(TARGETS)
 
 clean: subdirs-clean _clean
 
-realclean: subdirs-realclean _realclean
+realclean: subdirs-realclean _clean _realclean
 
 depend: subdirs-depend _depend
 
@@ -20,7 +29,7 @@
 
 clean: _clean
 
-realclean: _realclean
+realclean: _clean _realclean
 
 depend: _depend
 
@@ -38,29 +47,66 @@
 
 ######################################
 
+OBJS=$(subst .c,.o,$(SOURCES))
+
+ifdef MAKE_EXPORTS
+
+TO_CLEAN := $(TO_CLEAN) exports.c
+
+OBJS := $(OBJS) exports.o
+
+exports.c: $(SOURCES)
+	$(PERL) $(TOPDIR)/mkexports.pl $(MAKE_EXPORTS) exports.c $(SOURCES)
+
+endif
+
+ifdef MODULE
+
+ifneq ($(STATIC_MODULES),1)
+
+$(MODULE).so: $(OBJS) $(EXT_OBJS)
+	$(CC) $(CFLAGS) $(LDFLAGS) $(MODULE_LDFLAGS) $(OBJS) $(EXT_OBJS) -o $@
+
+module_install:
+	$(INSTALLDIR) $(MODULEDIR)
+	$(INSTALL) -m $(BIN_MODE) $(MODULE).so $(MODULEDIR)
+	# $(STRIP) $(MODULEDIR)/$(MODULE).so
+
+else
+
+$(MODULE).a: $(OBJS)
+	$(AR) $(ARFLAGS) $@ $+
+	$(RANLIB) $@
+
+module_install:
+
+endif
+
+.c.o:
+	$(CC) $(CFLAGS) $(MODULE_CFLAGS) -c $< -o $@
+
+else
+
 .c.o:
 	$(CC) $(CFLAGS) -c $< -o $@
 
-ifdef OBJS
+endif
 
 _clean: 
-	rm -f core $(DEPEND_FILE) $(OBJS)
+	rm -f core $(DEPEND_FILE) $(OBJS) $(TO_CLEAN)
 
-_depend:
-	$(MAKE_DEPEND) *.c
+_realclean:
+	rm -f $(TARGETS) $(TO_REALCLEAN)
 
+
+ifdef SOURCES
+_depend:
+	$(MAKE_DEPEND) $(SOURCES)
 else
-
-_clean:
-
 _depend:
 	
 endif
 
-_realclean: _clean
-	rm -f $(TARGETS)
-
-
 ######################################
 
 subdirs:
--- a/system.mk	Sat Apr 05 22:24:03 2003 +0200
+++ b/system.mk	Sat Apr 05 22:32:55 2003 +0200
@@ -7,24 +7,56 @@
 ## Installation paths
 ##
 
-PREFIX=/usr/local
+PREFIX=/usr/local/
 
 # No need to modify these usually
 BINDIR=$(PREFIX)/bin
 ETCDIR=$(PREFIX)/etc
 MANDIR=$(PREFIX)/man
 DOCDIR=$(PREFIX)/doc
-# Not used
+LIBDIR=$(PREFIX)/lib
 INCDIR=$(PREFIX)/include
-LIBDIR=$(PREFIX)/lib
 
 
 ##
 ## Modules
 ##
 
-#MODULE_SUPPORT=-DCF_NO_MODULE_SUPPORT
+MODULE_LIST=ionws floatws query
+
+# For dynamically loaded modules
 MODULE_SUPPORT_LDFLAGS=-export-dynamic -ldl
+MODULE_LDFLAGS=-shared
+MODULE_CFLAGS=-shared
+
+# Some strangely behaving OSes (NetBSD, OpenBSD, ...) might need this.
+#MODULE_SUPPORT_CFLAGS=-DCF_UNDERSCORED_MODULE_SYMBOLS
+MODULE_SUPPORT_CFLAGS=
+
+# Statically loaded modules
+#STATIC_MODULES=1
+#MODULE_SUPPORT_CFLAGS=
+#MODULE_SUPPORT_LDFLAGS=
+#MODULE_LDFLAGS=
+#MODULE_CFLAGS=
+
+##
+## Lua
+##
+
+# If you have Lua 5.0 in /usr/lib, the following should do:
+#LUA_LIBS = -llua -llualib
+#LUA_INCLUDES =
+
+# If you, for example, have lua 4.0 in /usr/lib and 5.0 somewhere else,
+# the following settings might be what you need. Lame ld.so on my system
+# searches /usr/lib before /usr/local/lib or anything in ld.so.conf so
+# the -Xlinker -rpath $(LUA_PATH) option is used to force sane library
+# lookup order instead of having the user set LD_LIBRARY_PATH. If you're
+# linking to static libraries, this option is not needed.
+LUA_PATH=/usr/local/lib
+LUA_LIBS = -L$(LUA_PATH) -Xlinker -rpath $(LUA_PATH) -llua -llualib
+LUA_INCLUDES = -I$(LUA_PATH)/include
 
 
 ##
@@ -32,17 +64,35 @@
 ##
 
 X11_PREFIX=/usr/X11R6
-
 # SunOS/Solaris
 #X11_PREFIX=/usr/openwin
 
-X11_LIBS=-L$(X11_PREFIX)/lib
+X11_LIBS=-L$(X11_PREFIX)/lib -lX11 -lXext
 X11_INCLUDES=-I$(X11_PREFIX)/include
-X11_DEFINES=
+
+# Change commenting to disable Xinerama support
+XINERAMA_LIBS=-lXinerama
+#DEFINES += -DCF_NO_XINERAMA
+
+# Uncomment to enable Xft (anti-aliased fonts) support
+#DEFINES += -DCF_XFT
+#X11_INCLUDES += `xft-config --cflags`
+#X11_LIBS += `xft-config --libs`
 
-#EXTRA_INCLUDES = -I$(PREFIX)/include
-#EXTRA_LIBS = -L$(PREFIX)/lib
+# Uncomment to enable UTF8 support. You must have XFree86 (4.x?) and C99
+# wide char support available (either libc directly or maybe libutf8+libiconv).
+# Although iconv (that is needed to convert to wchar_t -- which is not
+# necessarily ucs-4 -- to test character properties) is a standardised
+# function, encoding names unfortunately aren't and thus these also have to
+# specified here.
 
+# GNU/Linux and other glibc-2.2 based systems.
+#DEFINES += -DCF_UTF8 -DCF_ICONV_TARGET=\"WCHAR_T\" -DCF_ICONV_SOURCE=\"UTF-8\"
+
+# Systems that depend on libutf8 and libiconv might want these.
+#DEFINES += -DCF_UTF8 -DCF_LIBUTF8 -DCF_ICONV_TARGET=\"C99\" -DCF_ICONV_SOURCE=\"UTF-8\"
+#EXTRA_LIBS += -liconv -lutf8 -L/usr/local/lib
+#EXTRA_INCLUDES -I/usr/local/include
 
 ##
 ## libc
@@ -51,7 +101,7 @@
 # You may uncomment this if you know your system has
 # asprintf and vasprintf in the c library. (gnu libc has.)
 # If HAS_SYSTEM_ASPRINTF is not defined, an implementation
-# in libtu/sprintf_2.2/ is used.
+# in sprintf_2.2/ is used.
 #HAS_SYSTEM_ASPRINTF=1
 
 
@@ -79,11 +129,11 @@
 # sunos, (irix)
 #XOPEN_SOURCE=-ansi -D__EXTENSIONS__
 
-# Same as '-Wall -pedantic-errors' without '-Wunused' as callbacks often
+# Same as '-Wall -pedantic' without '-Wunused' as callbacks often
 # have unused variables.
 WARN=	-W -Wimplicit -Wreturn-type -Wswitch -Wcomment \
 	-Wtrigraphs -Wformat -Wchar-subscripts \
-	-Wparentheses -pedantic-errors -Wuninitialized
+	-Wparentheses -pedantic -Wuninitialized
 
 
 CFLAGS=-g -O2 $(WARN) $(DEFINES) $(INCLUDES) $(EXTRA_INCLUDES)
@@ -122,3 +172,10 @@
 DATA_MODE=664
 
 STRIP=strip
+
+##
+## Perl (mkexports.pl)
+##
+
+PERL=perl
+

mercurial