Skip to content

Instantly share code, notes, and snippets.

@paulsmith
Created August 24, 2012 12:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulsmith/3449860 to your computer and use it in GitHub Desktop.
Save paulsmith/3449860 to your computer and use it in GitHub Desktop.
diff -u -r c_only/Makefile plugins_darwin/Makefile
--- c_only/Makefile 2012-08-19 22:53:58.000000000 -0400
+++ plugins_darwin/Makefile 2012-08-24 08:00:34.000000000 -0400
@@ -10,7 +10,7 @@
PLUGIN_DIR = plugins
-all: htmlize_main $(PLUGIN_DIR)/tt.so $(PLUGIN_DIR)/narcissist.so
+all: htmlize_main $(PLUGIN_DIR)/tt.dylib $(PLUGIN_DIR)/narcissist.dylib
#
@@ -41,7 +41,7 @@
# to DSOs.
htmlize_main: htmlize_main.o htmlize.o db.o clib.a plugin_manager.o \
plugin_discovery.o
- $(CC) -o $@ $^ -ldl -Wl,--export-dynamic
+ $(CC) -o $@ $^ -ldl
#
# Plugins
@@ -49,15 +49,15 @@
$(PLUGIN_DIR)/tt.o: $(PLUGIN_DIR)/tt.c $(HTMLIZE_H)
$(CC) -c $< -o $@ $(CCOPT_SO) -I.
-$(PLUGIN_DIR)/tt.so: $(PLUGIN_DIR)/tt.o
- $(CC) -o $@ $^ -shared
+$(PLUGIN_DIR)/tt.dylib: $(PLUGIN_DIR)/tt.o
+ $(CC) -o $@ $^ -dynamiclib -flat_namespace -undefined suppress
$(PLUGIN_DIR)/narcissist.o: $(PLUGIN_DIR)/narcissist.c $(HTMLIZE_H)
$(CC) -c $< -o $@ $(CCOPT_SO) -I.
-$(PLUGIN_DIR)/narcissist.so: $(PLUGIN_DIR)/narcissist.o
- $(CC) -o $@ $^ -shared
+$(PLUGIN_DIR)/narcissist.dylib: $(PLUGIN_DIR)/narcissist.o
+ $(CC) -o $@ $^ -dynamiclib -flat_namespace -undefined suppress
clean:
- rm -rf core *.o *.a htmlize_main plugins/*.o plugins/*.so
+ rm -rf core *.o *.a htmlize_main plugins/*.o plugins/*.dylib
diff -u -r c_only/plugin_discovery.c plugins_darwin/plugin_discovery.c
--- c_only/plugin_discovery.c 2012-08-20 08:03:52.000000000 -0400
+++ plugins_darwin/plugin_discovery.c 2012-08-24 08:03:52.000000000 -0400
@@ -36,7 +36,7 @@
// Given a filename, return the name of the plugin (the filename
-// without .so extension) if it appears like a valid plugin path, or
+// without .dylib extension) if it appears like a valid plugin path, or
// NULL.
//
static dstring get_plugin_name(char* filename) {
@@ -46,8 +46,8 @@
char* name_start = last_slash ? last_slash + 1 : filename;
char* last_dot = strrchr(filename, '.');
- // We only care about file names that have a .so extension
- if (!last_dot || strcmp(last_dot, ".so"))
+ // We only care about file names that have a .dylib extension
+ if (!last_dot || strcmp(last_dot, ".dylib"))
return NULL;
return dstring_new_len(name_start, last_dot - name_start);
@paulsmith
Copy link
Author

Patch to get Eli Bendersky's C plugin example compiled on Darwin (OS X)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment