Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

build: separate configuration and rules #698

Closed
wants to merge 1 commit into from

2 participants

@errordeveloper

a) it's a good thing to separate these
b) one can do this:

# cat libuv-config.mk
include config-common.mk

%:
    @echo $($@)
# make -I import/johndoe/libuv -f libuv-config.mk LDFLAGS

would it be of interest to add actual libuv-config.mk from above?

@bnoordhuis

I'm afraid I landed a couple of commits just now that conflict with your PR.

make -I import/johndoe/libuv -f libuv-config.mk LDFLAGS

When / why would you want to do that? I'm not sure I follow.

@errordeveloper

That's basically kind of intending to serve the same purpose as libfoo-config --ldflags --cflags does, however the original reason for digging into this was to fix an issue where on Darwin I have had to pass -framework CoreServices in order to compile my code with uv.a.
It actually looks like that was an issue in v0.8 and it's not in master :smile:

@errordeveloper

@bnoordhuis it's fine by me if you wish to reject this as b was a slightly odd use case, and I'm not too strong on a after all ...

So as of master (at least) one shouldn't be able to compile with cc myprog.c libuv/uv.a, right?

@errordeveloper

I'm taking it back, I still have to pass -framework CoreServices.

So the point b of this PR still stands strong.

The idea of doing it this way is quite simple:

  1. one needs to build something that uses libuv
  2. the only tools at had is make (no cmake, gyp or anything of that kind)
  3. no code should be replicated from libuv makefiles, as it's hard to maintain

I have only tried this on Darwin, but I suspect all the other platform-specific LDFLAGS will get on the way and I'd need to copy quite few lines from config-unix.mk & config-mingw.mk. And this PR solves the problem upstream with just splitting makefiles and no effective change of build process.

@bnoordhuis

Closing, this PR no longer applies after the switch to autotools. Thanks though.

@bnoordhuis bnoordhuis closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 30, 2013
  1. @errordeveloper
This page is out of date. Refresh to see the latest.
View
17 build.mk
@@ -18,21 +18,8 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-OS ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
-
-CPPFLAGS += -I$(SRCDIR)/include -I$(SRCDIR)/include/uv-private
-
-ifeq (darwin,$(OS))
-SOEXT = dylib
-else
-SOEXT = so
-endif
-
-ifneq (,$(findstring mingw,$(OS)))
-include $(SRCDIR)/config-mingw.mk
-else
-include $(SRCDIR)/config-unix.mk
-endif
+include config-common.mk
+include $(RULES)
BENCHMARKS= \
test/benchmark-async-pummel.o \
View
37 config-common.mk
@@ -0,0 +1,37 @@
+# Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+OS ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
+
+CPPFLAGS += -I$(SRCDIR)/include -I$(SRCDIR)/include/uv-private
+
+ifeq (darwin,$(OS))
+SOEXT = dylib
+else
+SOEXT = so
+endif
+
+ifneq (,$(findstring mingw,$(OS)))
+include $(SRCDIR)/config-mingw.mk
+RULES := $(SRCDIR)/rules-mingw.mk
+else
+include $(SRCDIR)/config-unix.mk
+RULES := $(SRCDIR)/rules-unix.mk
+endif
View
15 config-mingw.mk
@@ -34,18 +34,3 @@ RUNNER_CFLAGS=$(CFLAGS) -D_GNU_SOURCE # Need _GNU_SOURCE for strdup?
RUNNER_LDFLAGS=$(LDFLAGS)
RUNNER_LIBS=-lws2_32 -lpsapi -liphlpapi
RUNNER_SRC=test/runner-win.c
-
-libuv.a: $(WIN_OBJS) src/fs-poll.o src/inet.o src/uv-common.o
- $(AR) rcs $@ $^
-
-src/%.o: src/%.c include/uv.h include/uv-private/uv-win.h
- $(CC) $(CFLAGS) -c $< -o $@
-
-src/win/%.o: src/win/%.c include/uv.h include/uv-private/uv-win.h src/win/internal.h
- $(CC) $(CFLAGS) -o $@ -c $<
-
-clean-platform:
- -rm -f src/win/*.o
-
-distclean-platform:
- -rm -f src/win/*.o
View
34 config-unix.mk
@@ -122,37 +122,3 @@ RUNNER_LDFLAGS += -pthreads
else
RUNNER_LDFLAGS += -pthread
endif
-
-libuv.a: $(OBJS)
- $(AR) rcs $@ $^
-
-libuv.$(SOEXT): override CFLAGS += -fPIC
-libuv.$(SOEXT): $(OBJS)
- $(CC) -shared -o $@ $^ $(LDFLAGS)
-
-include/uv-private/uv-unix.h: \
- include/uv-private/uv-bsd.h \
- include/uv-private/uv-darwin.h \
- include/uv-private/uv-linux.h \
- include/uv-private/uv-sunos.h
-
-src/unix/internal.h: src/unix/linux-syscalls.h
-
-src/.buildstamp src/unix/.buildstamp test/.buildstamp:
- mkdir -p $(dir $@)
- touch $@
-
-src/unix/%.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/internal.h src/unix/.buildstamp
- $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
-
-src/%.o: src/%.c include/uv.h include/uv-private/uv-unix.h src/.buildstamp
- $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
-
-test/%.o: test/%.c include/uv.h test/.buildstamp
- $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
-
-clean-platform:
- -rm -f libuv.a libuv.$(SOEXT) test/run-{tests,benchmarks}.dSYM
-
-distclean-platform:
- -rm -f libuv.a libuv.$(SOEXT) test/run-{tests,benchmarks}.dSYM
View
34 rules-mingw.mk
@@ -0,0 +1,34 @@
+# Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+libuv.a: $(WIN_OBJS) src/fs-poll.o src/inet.o src/uv-common.o
+ $(AR) rcs $@ $^
+
+src/%.o: src/%.c include/uv.h include/uv-private/uv-win.h
+ $(CC) $(CFLAGS) -c $< -o $@
+
+src/win/%.o: src/win/%.c include/uv.h include/uv-private/uv-win.h src/win/internal.h
+ $(CC) $(CFLAGS) -o $@ -c $<
+
+clean-platform:
+ -rm -f src/win/*.o
+
+distclean-platform:
+ -rm -f src/win/*.o
View
53 rules-unix.mk
@@ -0,0 +1,53 @@
+# Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+libuv.a: $(OBJS)
+ $(AR) rcs $@ $^
+
+libuv.$(SOEXT): override CFLAGS += -fPIC
+libuv.$(SOEXT): $(OBJS)
+ $(CC) -shared -o $@ $^ $(LDFLAGS)
+
+include/uv-private/uv-unix.h: \
+ include/uv-private/uv-bsd.h \
+ include/uv-private/uv-darwin.h \
+ include/uv-private/uv-linux.h \
+ include/uv-private/uv-sunos.h
+
+src/unix/internal.h: src/unix/linux-syscalls.h
+
+src/.buildstamp src/unix/.buildstamp test/.buildstamp:
+ mkdir -p $(dir $@)
+ touch $@
+
+src/unix/%.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/internal.h src/unix/.buildstamp
+ $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+
+src/%.o: src/%.c include/uv.h include/uv-private/uv-unix.h src/.buildstamp
+ $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+
+test/%.o: test/%.c include/uv.h test/.buildstamp
+ $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+
+clean-platform:
+ -rm -f libuv.a libuv.$(SOEXT) test/run-{tests,benchmarks}.dSYM
+
+distclean-platform:
+ -rm -f libuv.a libuv.$(SOEXT) test/run-{tests,benchmarks}.dSYM
Something went wrong with that request. Please try again.