Skip to content
Permalink
Browse files

add NO_GNU_GETOPT make flag, fix GCC warnings

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
  • Loading branch information...
tycho committed Jan 10, 2011
1 parent 360552a commit e7308b5616e9e59b3d122762ef476f9b405651a5
Showing with 10 additions and 7 deletions.
  1. +6 −1 Makefile
  2. +0 −4 getopt/getopt.h
  3. +4 −2 getopt/getopt_long.c
@@ -28,7 +28,7 @@ BINARY := cpuid$(EXT)
all: $(BINARY)

CC := gcc
CFLAGS := -Os -fno-strict-aliasing -std=gnu89 -Wall -Wextra -Wwrite-strings -pedantic -Wno-overlength-strings
CFLAGS := -Os -I. -fno-strict-aliasing -std=gnu89 -Wall -Wextra -Wwrite-strings -pedantic -Wno-overlength-strings
LDFLAGS :=
OBJECTS := cache.o cpuid.o feature.o handlers.o main.o util.o version.o

@@ -42,6 +42,11 @@ CFLAGS += -mdynamic-no-pic
LDFLAGS += -mdynamic-no-pic
endif

ifdef NO_GNU_GETOPT
CFLAGS += -Igetopt
OBJECTS += getopt/getopt_long.o
endif

ifeq (,$(findstring clean,$(MAKECMDGOALS)))
DEPS := $(shell ls $(OBJECTS:.o=.d) 2>/dev/null)

@@ -33,8 +33,6 @@
#ifndef _GETOPT_H_
#define _GETOPT_H_

// #include <sys/cdefs.h>

/*
* GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions
*/
@@ -56,7 +54,6 @@ struct option {
int val;
};

//__BEGIN_DECLS
int getopt_long(int, char * const *, const char *,
const struct option *, int *);
int getopt_long_only(int, char * const *, const char *,
@@ -73,7 +70,6 @@ extern int optopt;
extern int optreset;
extern char *suboptarg; /* getsubopt(3) external variable */
#endif
//__END_DECLS

#define MAX_ARGS 16
extern char *string_argv[MAX_ARGS];
@@ -54,6 +54,7 @@

#include <getopt.h>
#include <stdio.h>
#include <string.h>

#define warnx printf

@@ -80,7 +81,7 @@ int posixly_correct = 0;
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1

#define EMSG ""
#define EMSG (char *)""

static int getopt_internal(int, char * const *, const char *,
const struct option *, int *, int);
@@ -167,7 +168,8 @@ static int
parse_long_options(char * const *nargv, const char *options,
const struct option *long_options, int *idx, int short_too)
{
char *current_argv, *has_equal;
const char *current_argv;
char *has_equal;
size_t current_argv_len;
int i, match;

0 comments on commit e7308b5

Please sign in to comment.
You can’t perform that action at this time.