Skip to content

Commit

Permalink
linux compat
Browse files Browse the repository at this point in the history
  • Loading branch information
fizx committed Mar 23, 2013
1 parent b76eea3 commit 8c25b0e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
41 changes: 21 additions & 20 deletions extconf.rb
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
require 'mkmf'
# CONFIG['CC'] = "gcc"
CONFIG['optflags'] = "-O0"
$CFLAGS << ' -g -std=c99
-Wall -Wextra
-D_GNU_SOURCE
-DCOMPILE_WITH_DEBUG
-Wno-newline-eof
-Wno-declaration-after-statement
-Wno-comment
-Wno-sign-compare
-Wno-shorten-64-to-32
-Wno-switch-enum
-Wno-switch
-Wno-variadic-macros
-o sit'.gsub(/\s+/, " ")
CONFIG['optflags'] = "-Os"
$CFLAGS << '-std=c99 -D_GNU_SOURCE'

# -Wall -Wextra
# -Wno-newline-eof
# -Wno-declaration-after-statement
# -Wno-comment
# -Wno-sign-compare
# -Wno-shorten-64-to-32
# -Wno-switch-enum
# -Wno-switch
# -Wno-variadic-macros


headers = %w[/usr/local/include /usr/include]
libs = %w[/usr/local/lib /usr/lib]
out = `pcre-config --libs`[/-L(\S+)/, 1]
libs.unshift(out) if out
if out
libs.unshift(out)
puts "adding #{out} to search path"
end

find_library('ev', 'ev_default_loop', *libs) &&
find_header("pcre.h", *headers) &&
find_header("ev.h", *headers) &&
find_header("aio.h", *headers) &&
find_library('ev', 'ev_default_loop', *libs) &&
find_library('pcre', 'pcre_compile', *libs) &&
find_library('pcre', 'pcre_free_study', *libs) &&
find_header("pcre.h", *headers) &&
find_header("sys/queue.h", *headers) &&
create_makefile('sit') ||
abort("error")

footer = <<-STR
$(TARGET): $(OBJS) Makefile
$(ECHO) linking executable $(TARGET)
echo linking executable $(TARGET)
@-$(RM) $(@)
$(Q) $(CC) -dynamic -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
STR
Expand Down
3 changes: 2 additions & 1 deletion pstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ char *
pstrnstr(pstring *base, char *start, const char *c) {
if(start<base->val) return NULL;
int len = base->len - (start - base->val);
return strnstr(start, c, len);
int clen = strlen(c);
return memmem(start, len, c, clen);
}

char *
Expand Down

0 comments on commit 8c25b0e

Please sign in to comment.